package com.blackoreo.monitor.conf;

/**
 * PackageName: com.blackoreo.monitor.conf
 * Author: txw
 * Date: 2021/4/8
 * Description: conf
 */
public class BlackOreoConf {


    public static final Conf PORT = new Conf("black.oreo.monitor.port", 8080);
    public static final Conf PATH = new Conf("black.oreo.monitor.dashboard", "/");
    public static final Conf THREAD_NAME = new Conf("black.oreo.monitor.thread.name", "black-oreo-monitor-listener");


    public static class Conf {
        private String propertiesName;
        private Object value;
        private Object defaultVal;

        public Conf(String propertiesName, Object defaultVal) {
            this.propertiesName = propertiesName;
            this.defaultVal = defaultVal;
        }

        public Object getValue() {
            if (null != System.getProperty(propertiesName)) {
                this.value = System.getProperty(propertiesName);
                return System.getProperty(propertiesName);
            }
            return defaultVal;
        }

        public String getPropertiesName() {
            return propertiesName;
        }

        public Object getDefaultVal() {
            return defaultVal;
        }
    }

}
